package com.cqhilink.iot.jobstandardmanagement.services.innerservice.impl.workcellinfo;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.cqhilink.iot.jobstandardmanagement.dao.mapper.DataSrcMapper;
import com.cqhilink.iot.jobstandardmanagement.facade.model.BootstrapSearchBean;
import com.cqhilink.iot.jobstandardmanagement.facade.model.DataSrc;
import com.cqhilink.iot.jobstandardmanagement.facade.service.workcellinfo.JsmIDataSrcService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/1/10.
 */

public class JsmDataSrcService implements JsmIDataSrcService {

    @Autowired
    private DataSrcMapper dataSrcMapper;

    /**
     * 根据生产单元加载数据集
     */
    @Override
    public JSONObject loadEntityDateSetByCellId(String cellId, BootstrapSearchBean bootstrapSearchBean) {
        Map map = new HashMap<>();
        map.put("cellId", null == bootstrapSearchBean.getSearch() ? cellId : bootstrapSearchBean.getSearch());
        bootstrapSearchBean.setInitParam(map);
        JSONObject jsonObject = new JSONObject();
        List<DataSrc> abnormalTypeList = dataSrcMapper.queryTableList(bootstrapSearchBean);//查询列表数据
        jsonObject.put("rows", JSON.toJSON(abnormalTypeList));
        //返回结果
        return jsonObject;
    }
}
